﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UIT.Controls;
using System.Windows.Markup;

#if !SILVERLIGHT
namespace UIT.WPF
#else
namespace UIT.Silverlight
#endif
{
    [ContentProperty("Child")]
    public class WpfControlHost : Control
    {
        private System.Windows.FrameworkElement child;

        public System.Windows.FrameworkElement Child
        {
            get { return child; }
            set
            {
                if (child != null)
                    child.DataContext = null;
                child = value;
                if (child != null)
                    child.DataContext = DataContext;
            }
        }

        public override object DataContext
        {
            get
            {
                return base.DataContext;
            }
            set
            {
                base.DataContext = value;
                if (child != null)
                    child.DataContext = value;
            }
        }


        public override bool IsContainer
        {
            get { return false; }
        }

        public override ControlType Type
        {
            get { return ControlType.Specific; }
        }
    }
}
